#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int l,r,n,mid,ans;
int a[N];
bool check(int liv){
    int i=1,j=1;
    for(;i<=n-liv;i++){
        if(j>n) return 0;
        while(a[j]<=a[i]&&j<=n){
            j++;
        }
        if(j>n) return 0;
        j++;
    }
    return 1;
}
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n;
    l=1;r=n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    while(l<=r){
        mid=(l+r)/2;
        if(check(mid)){
            ans=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    cout<<ans;
    return 0;
}
